<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>管理员页面</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <h2 class="title">管理员页面</h2>
    <div class="container">
        <form action="AdminServlet" method="post">
            <input type="hidden" name="action" value="save">
            <input type="submit" value="保存分组结果">
        </form>
        <div class="group-list">
            <c:forEach var="entry" items="${groups}">
                <div class="group">
                    <div class="group-title">${entry.key}组</div>
                    <c:forEach var="student" items="${entry.value}">
                        ${student.name}，${student.studentId}
                        <form action="AdminServlet" method="post" style="display:inline;">
                            <input type="hidden" name="action" value="remove">
                            <input type="hidden" name="studentId" value="${student.studentId}">
                            <input type="submit" value="删除">
                        </form>
                        <br>
                    </c:forEach>
                </div>
            </c:forEach>
        </div>
        
        <div class="add-student">
	        <form action="AdminServlet" method="post">
	            <input type="hidden" name="action" value="add">
	            姓名：<input type="text" name="name" required>
	            学号：<input type="text" name="studentId" required>
	            分组编号：<input type="number" name="groupNumber" min="1" max="10" required>
	            <input type="submit" value="添加学生">
	        </form>
	        <c:if test="${not empty error}">
	            <p class="error">${error}</p>
	        </c:if>
        </div>
    </div>
</body>
</html>
